<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="../../mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加新地址</title>
    <t:base type="jquery"></t:base>
    <script type="text/javascript" src="webpage/com/wx/added_product/procurement/shoppingCar.js"></script>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>

    <script type="text/javascript" charset="utf-8">
        mui.init();
    </script>

</head>
<body>
<div class="tel"><a href="tel:400-88-22726"> <img src="${webRoot }images/tel.jpg"></a></div>
<t:formvalid formid="formobj" dialog="false" usePlugin="password" layout="table"
             action="zyCommonAddressController.do?doAdd" tiptype="tipType"  validFormName="validFormName" showAllError="false" callback="subCallBack">
    <input type="hidden" name="id" value="${ad.id}"/>
    <div class="mui-card" style="width:100%;margin:0px;">
        <ul class="mui-table-view">
            <li class="mui-table-view-cell">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px; text-align: right; padding-right: 10px;">联系人姓名 </span>
                <div class="mui-input-row">
                    <input id='contactName' name="contactName" type="text" class=" mui-input"
                           nullmsg="请填写联系人姓名" datatype="*2-10"
                           style="width:90%; margin-bottom: 0; height: 30px; margin: 5px 0; font-size: 14px;"
                           value="${ad.contactName}">
                </div>
            </li>
            <li class="mui-table-view-cell">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px; text-align: right; padding-right: 10px;">邮箱 </span>
                <div class="mui-input-row">
                    <input id='mail' name="mail" type="text" class=" mui-input" datatype="e" nullmsg="请填写邮箱信息"  ignore="ignore"
                           style="width:90%; margin-bottom: 0; height: 30px; margin: 5px 0; font-size: 14px;"
                           value="${ad.mail}">
                </div>
            </li>
            <li class="mui-table-view-cell" style="margin-top: 0;">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px;text-align: right; padding-right: 10px">电话</span>
                <div class="mui-input-row">
                    <input id='phone' name="phone" type="text" class=" mui-input" datatype="cPhone" nullmsg="请填写手机号码" errormsg="手机号码格式不正确"
                           style="width:90%; margin-bottom: 0; height: 30px; margin: 5px 0; font-size: 14px;"
                           value="${ad.phone}">
                </div>
            </li>
            <li class="mui-table-view-cell">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px; text-align: right; padding-right: 10px;">所属影院 </span>
                <div class="mui-input-row">
                    <input id='belongCinema' name="belongCinema" type="text" class=" mui-input"  ignore="ignore"
                           style="width:90%; margin-bottom: 0; height: 30px; margin: 5px 0; font-size: 14px;"
                           value="${ad.belongCinema}">
                </div>
            </li>
            <li class="mui-table-view-cell" style="margin-top: 0;">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px;text-align: right; padding-right: 10px">详细地址</span>
                <textarea class="ww" style="width: 65%" id='fullAddress' name="fullAddress" placeholder="请填写详细地址，不少于5个字" datatype="*5-50">${ad.fullAddress}</textarea>
            </li>
            <li class="mui-table-view-cell" style="margin-top: 0;">
                <span style="width: 100px; float: left; line-height: 40px; font-size: 14px;text-align: right; padding-right: 10px">是否默认</span>
                <div id='switch-div' class="mui-switch mui-switch-mini">
                    <div class="mui-switch-handle"></div>
                </div>
                <input type="hidden" id="isDefault" name="isDefault" value="${ad.isDefault}"/>
            </li>
        </ul>
    </div>
    <div class="mui-clearfix"></div>

    <div style="width:92%;margin: 1em auto;">
        <a class="mui-btn mui-btn-block mui-btn-primary" href="javascript:saveAddress();" id="subOrder" style="font-size:1.6em !important;">确认</a>
    </div>
</t:formvalid>
</body>
<script type="text/javascript">
    /**验证提示*/
    function tipType(msg,o,cssctl){
        if(o.type == 3){
            mui.toast(msg);
        }
    }
    function subCallBack(data) {
        mui.openWindow({
            createNew : true,
            url : "shoppingcar.do?goChooseContacts"
        })
    }
    function saveAddress() {
        $("#formobj").submit();
    }

    $(function(){

        if($("#isDefault").val() == '1'){
            $("#switch-div").addClass("mui-active");
        }
        $("#isDefault").val("${ad.isDefault}" || 0);

        document.getElementById("switch-div").addEventListener("toggle",function(event){
            if(event.detail.isActive){
                $("#isDefault").val(1);
            }else{
                $("#isDefault").val(0);
            }
        })
    })
</script>
</html>